using System;
using System.Reflection;
using Microsoft.Office.Project.EPMAuditing.Library;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;

namespace Microsoft.Office.Project.EPMAuditing.EventHandlers
{
    public class CalendarEvents : CalendarEventReceiver
    {
        public override void OnChanged(PSContextInfo contextInfo, CalendarPostEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnChanging(PSContextInfo contextInfo, CalendarPreEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCheckedIn(PSContextInfo contextInfo, CalendarCheckInPostEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCheckedOut(PSContextInfo contextInfo, CalendarCheckOutPostEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCheckingIn(PSContextInfo contextInfo, CalendarCheckInPreEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCheckingOut(PSContextInfo contextInfo, CalendarCheckOutPreEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCreated(PSContextInfo contextInfo, CalendarPostEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnCreating(PSContextInfo contextInfo, CalendarPreEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnDeleted(PSContextInfo contextInfo, CalendarDeletePostEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }

        public override void OnDeleting(PSContextInfo contextInfo, CalendarDeletePreEventArgs e)
        {
            AuditEvent ae = new AuditEvent(DateTime.Now, MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, contextInfo, e);
            ae.Post();
        }
    }
}
